package com.kaishengit.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.PublishService;

import com.kaishengit.entity.Publish;
import com.kaishengit.util.web.ServletUtil;

public class PublishEdit extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private PublishService service=new PublishService();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		Publish publish=service.findById(id);
		ServletUtil.setRequestAttribute(request, "publish", publish);
		ServletUtil.forward(request, response, "/admin/publishEdit");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id=request.getParameter("id");
		String publishName=request.getParameter("publishName");
		service.updatePublish(id,publishName);
		
		ServletUtil.redirect(response, "publishManager.jspx");
	}

}
